home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / simplify.rep / code.ys < prev   
Encoding:
Text File  |  2002-03-13  |  2.7 KB  |  86 lines

  1.  
  2.  
  3. 10 # Simplify(expr_IsList) <-- MapSingle("Simplify",expr);
  4.  
  5. 15 # Simplify(Complex(_r,_i)) <-- Complex(Simplify(r),Simplify(i));
  6.  
  7. 20 # Simplify((_xex) == (_yex)) <-- (Simplify(xex-yex) == 0);
  8.  
  9. 20 # Simplify((_xex) > (_yex)) <-- (Simplify(xex-yex) > 0);
  10. 20 # Simplify((_xex) < (_yex)) <-- (Simplify(xex-yex) < 0);
  11. 20 # Simplify((_xex) >= (_yex)) <-- (Simplify(xex-yex) >= 0);
  12. 20 # Simplify((_xex) <= (_yex)) <-- (Simplify(xex-yex) <= 0);
  13. 20 # Simplify((_xex) !== (_yex)) <-- (Simplify(xex-yex) !== 0);
  14.  
  15. 50 # Simplify(_expr) <-- MultiSimp(Eval(expr));
  16.  
  17.  
  18. Eliminate(_var,_replace,_function) <-- Simplify(Subst(var,replace)function);
  19. ExpandBrackets(_xx) <-- SimpExpand(SimpImplode(SimpFlatten(xx)));
  20.  
  21. Function("Flatten",{body,flattenoper})
  22. [
  23.   DoFlatten(body);
  24. ];
  25.  
  26. RuleBase("DoFlatten",{doflattenx});
  27. UnFence("DoFlatten",1);
  28.  
  29. 10 # DoFlatten(_doflattenx)_(Type(doflattenx)=flattenoper) <--
  30.      Apply("Concat",MapSingle("DoFlatten",Tail(Listify(doflattenx))));
  31. 20 # DoFlatten(_doflattenx) <-- { doflattenx };
  32.  
  33.  
  34. 10 # UnFlatten({},_op,_identity) <-- identity;
  35. 20 # UnFlatten(list_IsList,_op,_identity) <--
  36.      Apply(op,{Head(list),UnFlatten(Tail(list),op,identity)});
  37.  
  38.  
  39. RuleBase("SimpAdd",{x,y});
  40. RuleBase("SimpMul",{x,y});
  41. RuleBase("SimpDiv",{x,y});
  42.  
  43.  
  44. 10 # SimpFlatten((_x)+(_y)) <-- SimpAdd(SimpFlatten(x),SimpFlatten(y));
  45. 10 # SimpFlatten((_x)-(_y)) <-- SimpAdd(SimpFlatten(x),SimpMul(-1,SimpFlatten(y)));
  46. 10 # SimpFlatten(    -(_y)) <-- SimpMul(-1,SimpFlatten(y));
  47.  
  48. 10 # SimpFlatten((_x)*(_y)) <-- SimpMul(SimpFlatten(x),SimpFlatten(y));
  49. 10 # SimpFlatten((_x)/(_y)) <-- SimpDiv(SimpFlatten(x),SimpFlatten(y));
  50. 10 # SimpFlatten((_x)^(n_IsPositiveInteger)) <--
  51.      SimpMul(SimpFlatten(x),SimpFlatten(x^(n-1)));
  52.  
  53. 100 # SimpFlatten(_x) <--
  54. [
  55.   x;
  56. ];
  57.  
  58. 10 # SimpExpand(SimpAdd(_x,_y)) <-- SimpExpand(x) + SimpExpand(y);
  59. 10 # SimpExpand(SimpMul(_x,_y)) <-- SimpExpand(x) * SimpExpand(y);
  60. 10 # SimpExpand(SimpDiv(_x,_y)) <-- SimpExpand(x) / SimpExpand(y);
  61. 20 # SimpExpand(_x) <-- x;
  62.  
  63. /* Distributed multiplication rule */
  64. 10 # SimpImplode(SimpMul(SimpAdd(_x,_y),_z)) <--
  65.      SimpImplode(SimpAdd(SimpImplode(SimpMul(x,z)),
  66.                  SimpImplode(SimpMul(y,z))));
  67. 10 # SimpImplode(SimpMul(_z,SimpAdd(_x,_y))) <--
  68.      SimpImplode(SimpAdd(SimpImplode(SimpMul(z,x)),
  69.                  SimpImplode(SimpMul(z,y))));
  70. /* Distributed division rule  */
  71. 10 # SimpImplode(SimpDiv(SimpAdd(_x,_y),_z)) <--
  72.      SimpImplode(SimpAdd(SimpImplode(SimpDiv(x,z)),
  73.      SimpImplode(SimpDiv(y,z))));
  74.  
  75.  
  76.  
  77. 20 # SimpImplode(SimpAdd(_x,_y)) <--
  78.      SimpAdd(SimpImplode(x),SimpImplode(y));
  79. 20 # SimpImplode(SimpMul(_x,_y)) <--
  80.      SimpMul(SimpImplode(x),SimpImplode(y));
  81. 20 # SimpImplode(SimpDiv(_x,_y)) <--
  82.      SimpDiv(SimpImplode(x),SimpImplode(y));
  83. 30 # SimpImplode(_x) <-- x;
  84.  
  85.  
  86.